.Dd 2023-08-19
.Dt ANACRONTAB 5
.Os systemd-cron @version@
.
.Sh NAME
.Nm /etc/anacrontab
.Nd monotonic jobs
.
.Sh DESCRIPTION
The file
.Nm
follows the rules previously set by \fBanacron(8)\fR.
.Pp
Lines starting with
.Sq Sy #
are comments.
.Pp
Environment variables can be set using
.Va variable Ns = Ns Fa value
alone on a line.
.Pp
The special
.Sy RANDOM_DELAY
(in minutes) environment variable is translated to
.Sy RandomizedDelaySec= .
.Pp
The special
.Sy START_HOURS_RANGE
(in hours) environment variable is translated to the hour
component of
.Sy OnCalendar= .
anacron expects a range in the format
.Va start Ns - Ns Va end ,
but
.Nm systemd-crontab-generator
only uses
.Va start .
.Pp
The other lines are job-descriptions in the white-space-separated format
.D1 Va period  delay  job-identifier  command
where
.Bl -tag -compact -width ".Va job-identifier" -offset 6n
.It Va period
is a number of days to wait between each job execution, or one of the special values
.Sy @reboot ,
.Sy @minutely ,
.Sy @hourly ,
.Sy @midnight ,
.Sy @daily ,
.Sy @weekly ,
.Sy @monthly ,
.Sy @quarterly ,
.Sy @semi-annually ,
.Sy @yearly .
.
.It Va delay
is the number of extra minutes to wait before starting job,
translated to
.Sy OnBootSec= ,
.
.It Va job-identifier
is a single word used by
.Nm systemd-crontab-generator
to construct dynamic unit names in the form
.Sy cron-anacron- Ns Va job-identifier Ns Sy - Ns Ar MD5 Ns Sy .\& Ns Brq Sy timer , service ,
.
.It Va command
is the program to run by the shell.
.El
.
.Sh BUGS
.Nm systemd-crontab-generator
doesn't support multiline commands.
.Pp
Any
.Va period
greater than
.Em 30
is rounded to the closest month.
.Pp
There are subtle differences on how anacron and systemd handle persistent timers:
anacron will run a weekly job at most once a week, with a guaranteed minimum delay of 6 days
between runs, whereas systemd will try to run it every monday at midnight, or at system boot.
In the most extreme case, if a system was booted on sunday,
weekly jobs will run that day and the again the next (mon)day.
.Pp
There is no difference for the daily job.
.
.Sh NOTES
Real anacron only accepts
.Sy @monthly
and
.Sy @yearly
as
.Va period ;
all others listed above are
.Xr systemd.cron 7 Ns 's
extensions.
.Pp
Unlike
.Xr crontab 5 ,
every
.Xr anacrontab 5
job is persistent by default.
.
.Sh DIAGNOSTICS
After editing
.Nm ,
you can run
.Nm journalctl Fl n
and
.Nm systemctl Cm list-timers
to see if the timers have well been updated.
.
.Sh SEE ALSO
.Xr systemd.timer 5 ,
.Xr systemd-crontab-generator 8
.
.\".Sh AUTHOR
.\".An Alexandre Detiste Aq Mt alexandre@detiste.be
